<template>
  <div class="ask-record-list">
    <scroller  lock-x scrollbar-y height="-40" use-pullup :pullup-config="pullupConfig2" ref="demo2" @on-pullup-loading="load2">
      <ul>
        <li class="" v-for="(item, index) in dataList" :key="index" @click="linkToDetail(item.id)">
          <div class="flex-box-align">
            <p class="flex">{{item.patientUserCoreDTO.trueName}}</p>
            <p>{{item.secondInquiryTime}}</p>
          </div>
          <div>{{item.province}}{{item.city}}{{item.district}}</div>
        </li>
      </ul>
      <div v-if="noData" class="no-data">没有更多内容</div>
    </scroller>

  </div>
</template>
<script>
  import { Scroller } from 'vux';
  import {parseUrlParams} from "../../../wechat/static/util/util";
  let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");

  export default {
    data() {
      return {
        results: [],
        value: "",
        dataList: [],
        pullupConfig2: {
          content: '上拉加载更多',
          downContent: '松开进行加载',
          upContent: '上拉加载更多',
          loadingContent: '加载中...'
        },
        pageIndex:1,
        dataForm:'',
        loading:true,
        noData:false
      }
    },
    components: {
      Scroller,
    },
    mounted() {
      this.getList()
    },
    methods: {
      load2 () {
        if(!this.loading) return false;
        let { pageIndex, pageCount} = this.dataForm;
        if (pageCount <= this.pageIndex){
          setTimeout(() => {
            this.$refs.demo2.disablePullup()
            this.noData = true
          }, 100)
          return false;
        }
        this.loading = false;
        this.pageIndex++;
        setTimeout(() => {
          this.getList()
          this.$refs.demo2.donePullup()
        }, 100)
      },
      getList() {
        let  url = CONSTANT.URL.PATIENT.INQUIRYLIST,
          param = {pageIndex:this.pageIndex,pageSize:10}
        common.requestAjax(url,JSON.stringify({patientId: parseUrlParams("id")}),param,(res)=>{
          if(res.status == 200){
            this.loading = true;
            let data = res.data,
              pageCount = data.pageCount,
              bussData = data.bussData
            if(pageCount == 0||pageCount == 1){
              this.$refs.demo2.disablePullup()
              this.noData = true
            }
            this.dataForm = data;
            this.dataList =  this.pageIndex <= pageCount ? this.dataList.concat(bussData) : this.dataList
          }else{

          }
        })
      },
      linkToDetail(id) {
        this.$router.push({path: "/ask/detail", query: {id: id}})
      }
    }
  };
</script>
<style lang="less">
  .xs-plugin-pullup-container{
    font-size: 12px;
    bottom: -50px;
  }
  .no-data{
    padding-top: .5rem;
    color: #999;
    font-size: 14px;
    bottom: 0rem;
    text-align: center;
    position: relative;
  }
  .ask-record-list {
    font-size: .34rem;
    height: 100%;
    background: #f4f4f4;
    padding: .4rem .3rem;
    ul {
      li {
        background-color: #fff;
        padding: .29rem .26rem;
        margin-bottom: .3rem;
        div {
          &:first-child {
            margin-bottom: .29rem;
            p:last-child {
              color: #999;
              font-size: .24rem;
            }
          }
          &:last-child {
            font-size: .28rem;
          }
        }
      }
    }
  }
</style>
